#pragma once

#include "stdafx.h"
#include <windows.foundation.h>
#include <windows.media.h>

using namespace Microsoft::WRL;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Media;

extern HRESULT WINAPI CreateFFByteStreamHandler(IMFByteStreamHandler** ppv);
extern HRESULT WINAPI CreateFFMediaSource(IMFMediaSource** ppv);
extern HRESULT WINAPI CreateFFSourceMFActivate(IMFActivate** ppv);

class CFFByteStreamHandler WrlSealed : 
	public RuntimeClass<RuntimeClassFlags<RuntimeClassType::WinRtClassicComMix>,
		ABI::Windows::Media::IMediaExtension,
		IMFByteStreamHandler>
{
	InspectableClass(L"WPlayerByteStreamSource.CFFByteStreamHandler",BaseTrust)
public:
	CFFByteStreamHandler()
	{
		CreateFFByteStreamHandler(&pThunk);
	}
	~CFFByteStreamHandler()
	{
		SAFE_RELEASE(pThunk);
	}
public:
	STDMETHODIMP BeginCreateObject(IMFByteStream* pByteStream,LPCWSTR pwszURL,DWORD dwFlags,IPropertyStore* pProps,IUnknown** ppIUnknownCancelCookie,IMFAsyncCallback* pCallback,IUnknown* punkState);
	STDMETHODIMP EndCreateObject(IMFAsyncResult* pResult,MF_OBJECT_TYPE* pObjectType,IUnknown** ppObject);
	STDMETHODIMP CancelObjectCreation(IUnknown* pIUnknownCancelCookie) {return E_NOTIMPL;}
	STDMETHODIMP GetMaxNumberOfBytesRequiredForResolution(QWORD* pqwBytes) {return E_NOTIMPL;}
public:
	STDMETHODIMP SetProperties(ABI::Windows::Foundation::Collections::IPropertySet* pConfiguration) {return S_OK;}
private:
	IMFByteStreamHandler* pThunk = NULL;
};
ActivatableClass(CFFByteStreamHandler)